home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / headers / process.h < prev    next >
Encoding:
Text File  |  2000-09-28  |  3.3 KB  |  110 lines

  1. /*
  2.     File:        Process.h
  3.  
  4.     Contains:    TProcess is a Process Manager class.
  5.                   Process.h contains the header file information for the TProcess class construction.
  6.   
  7.  
  8.     Written by: Kent Sandvik    
  9.  
  10.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  11.  
  12.                 You may incorporate this Apple sample source code into your program(s) without
  13.                 restriction. This Apple sample source code has been provided "AS IS" and the
  14.                 responsibility for its operation is yours. You are not permitted to redistribute
  15.                 this Apple sample source code as "Apple sample source code" after having made
  16.                 changes. If you're going to re-distribute the source, we require that you make
  17.                 it clear in the source that the code was descended from Apple sample source
  18.                 code, but that you've made changes.
  19.  
  20.     Change History (most recent first):
  21.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  22.                 
  23.  
  24. */
  25. // Declare label for this header file
  26. #ifndef _PROCESS_
  27. #define _PROCESS_
  28.  
  29.  
  30. #ifndef _DTSCPLUSLIBRARY_
  31. #include "DTSCPlusLibrary.h"
  32. #endif
  33.  
  34. //    Toolbox Include Files
  35.  
  36. #ifndef __PROCESSES__
  37. #include <Processes.h>
  38. #endif
  39.  
  40. #ifndef __APPLEEVENTS__
  41. #include <AppleEvents.h>
  42. #endif
  43.  
  44. #ifndef __OSUTILS__
  45. #include <OSUtils.h>
  46. #endif
  47.  
  48. //    GLOBAL TYPEDEFS AND ENUMS
  49. const ProcessSerialNumber kMyProcess = {
  50.                                         kNoProcess, kNoProcess};
  51.  
  52.  
  53. // _________________________________________________________________________________________________________ //
  54. //    Class Interface
  55.  
  56. class TProcess
  57. // The TProcess class provides information from the Process Manager.
  58. {
  59. public:
  60.     //    CONSTRUCTORS & DESTRUCTORS
  61.     TProcess(ProcessSerialNumber = kMyProcess);    // default constructors
  62.     virtual~ TProcess();                        // virtual destructor
  63.  
  64.     //  MAIN INTERFACE
  65.     virtual Boolean KillApplication(ProcessSerialNumber*);// quit the application
  66.     virtual short GetNumProcesses();            // get the N amount of currently running procs
  67.     virtual ProcessInfoRec GetProcessInfoRec();    // fetch the whole process info rec
  68.     virtual unsigned long GetProcessSize();        // get the size of the process
  69.     virtual unsigned long GetFreeMem();            // get free memory available for the process
  70.     virtual unsigned long GetLaunchDate();        // get in seconds the launch time
  71.     virtual Boolean FindProcess(OSType signature);// find process with the right signature
  72.  
  73.     //    PUBLIC ACCESSORS AND MUTATORS            
  74.     virtual ProcessSerialNumber GetMyProcessID() const;
  75.     virtual ProcessSerialNumber GetProcessID() const;
  76.  
  77.     // ITERATORS
  78.     virtual void Next();                        // next PSN
  79.     virtual Boolean Last();                        // last PSN?
  80.     virtual void First();                        // reset to first PSN
  81.  
  82.     //    INITIATION ROUTINES                        
  83. protected:
  84.     virtual Boolean IProcess();                    // initialize needed class information
  85.  
  86.     //    FIELDS
  87. private:
  88.     ProcessSerialNumber fProcessID;                // any specific PSN number
  89.     ProcessSerialNumber fMyProcessID;            // our PSN number
  90.     ProcessSerialNumber fFirstPSN;                // the first one we got
  91.     Boolean fFirstTime;                            // signals order of iterators
  92.     Boolean fLast;                                // used to signal last process in an iterator list
  93.     Boolean fState;                                // state of the object
  94.     OSErr fError;                                // latest toolbox error
  95. };
  96.  
  97.  
  98. #endif
  99.  
  100. // _________________________________________________________________________________________________________ //
  101.  
  102.  
  103. /*    Change History (most recent last):
  104.   No        Init.    Date        Comment
  105.   1            khs        6/10/92        New file
  106.   2            khs        7/6/92        First decent working class
  107. */
  108.  
  109.  
  110.